//*********************************************************
// Subroutine for calculating vertex point light attenuation
//
// define SHIFT to select shift for current point light data
//
// Output Registers used:
//   to r0 - normalized vertex to light vector
//   to r1.w attenuation
//
//*********************************************************

// Point light
sub r0, c[SHIFT + VL_MODEL_SPACE_LIGHT_POS], inPos	// r0 = SLight Position - vertex_pos
dp3 r1.w, r0, r0	//r1.w = dist ^ 2
rsq r0.w, r1.w		//r0.w = 1/dist

//calculate attenuation factor
dst r1, r1.wwww, r0.wwww	//r1 = ( 1, dist, dist^2, 1/dist )
dp3 r1.w, r1, c[SHIFT + VL_ATTENUATION_C_L_Q_TABLEMUL]		//constant, linear or quadratic
rcp r1.w, r1.w			//r1.w = 1/dist^n
mul r1.w, r1.w, c[SHIFT + VL_PLIGHT_OORANGE_RANGE_SHADOWLENGTH_INTENSITY].w	//r1.w = intensity/dist^n

mul r0, r0, r0.w		//r0 = normalized vertex to light vector